/*
 * rate_list.h
 *
 *  Created on: 2011-8-23
 *      Author: lius
 */

#ifndef RATE_LIST_H_
#define RATE_LIST_H_
#include <sys/time.h>

enum{
	RATE_UNIT_SECOND = 0,
	RATE_UNIT_MINUTE,
	RATE_UNIT_HOUR
};

typedef struct _rate_node_{
	struct timeval cur_time;
	long value;
} rate_node_t;

typedef struct _rate_{
	rate_node_t *rate_array;               //value array
	unsigned int array_size;
	int index;
	int unit_type;                         //S,M,H .etc
	int interval;
}rate_t;

int init_rate_list(rate_t *prate, time_t duration, int unit_type);
int start_rate_count(rate_t *prate, int value);
int step_rate_count(rate_t *prate, int value);
void add_rate_count(rate_t *prate, int value);
int end_rate_count(rate_t *prate, int value);
int exit_rate_list(rate_t *prate);

#endif /* RATE_LIST_H_  */
